package com.xiaoming.api;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
public class ViewController {

    @RequestMapping(value = "/login")
    public String login(HttpServletRequest req, HttpServletResponse resp, String username, String pwd) throws IOException {
        if("admin".equals(username)&&"admin".equals(pwd)){
            HttpSession session = req.getSession();
            session.setAttribute("user","admin");
            resp.sendRedirect("resume");
            System.out.println("用户已登陆");
            return "resume";
        }
        return "index";
    }
    @RequestMapping("/")
    public String index(){
        return "index";
    }
    @RequestMapping("/resume")
    public String jumpToList(){
        return "resume";
    }
}
